﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BasicModuleWebApiJWTAuthorization.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ProductController : ControllerBase
    {
        public ProductController() 
        {

        }

        /// <summary>
        /// 使用jwt认证
        /// </summary>
        /// <returns></returns>
        [Authorize("Producd.Select")]
        [HttpGet("GetProduct")]
        public string GetProduct() 
        {
            var bl = HttpContext.User.Identity.IsAuthenticated;
            string claem = HttpContext.User.Identity.Name;
            var claims = HttpContext.User.Claims;
            var xx = HttpContext.User.Claims.Where(x => x.Type == "name").FirstOrDefault();
            var ww = HttpContext.User.Claims.Where(x => x.Type == "Passwd").FirstOrDefault();
            return "Ok";
        }
    }
}
